package org.eclipsecon.dui.interpreter.internal;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.swt.widgets.Control;

public class SWTControlAdapter extends AdapterImpl {

	private Control defaultControl = null;
	private Map<EObject, Control> map = new HashMap<EObject, Control>();

	public SWTControlAdapter(Control control) {
		defaultControl = control;
	}

	public SWTControlAdapter() {
	}

	public void setControl(EObject context, Control control) {
		if ( context == null) {
			defaultControl = control;
		}else {
			map.put(context, control);
		}
	}
	
	public Control getControl(EObject context) {
		if ( context == null) {
		return defaultControl;
		}
		return map.get(context);
	}
	
	@Override
	public boolean isAdapterForType(Object type) {
		return type == SWTControlAdapter.class;
	}
}
